package ru.kruzhki.client.ui.main;

import ru.kruzhki.client.place.NameTokens;
import ru.kruzhki.client.ui.searchform.SearchFormPresenter;

import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.gwt.user.client.ui.Label;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.annotations.NameToken;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.ProxyPlace;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;
import com.gwtplatform.mvp.client.proxy.RevealRootContentEvent;

public class MainPagePresenter extends
		Presenter<MainPagePresenter.MyView, MainPagePresenter.MyProxy> {
	
	public interface MyView extends View {
		//gwtp boilerplate
	}
	 
	@ProxyCodeSplit
	@NameToken(NameTokens.main)
	public interface MyProxy extends ProxyPlace<MainPagePresenter> {
		//gwtp boilerplate
	}
	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_header = new Type<RevealContentHandler<?>>();
	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_content = new Type<RevealContentHandler<?>>();
	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_sideLeft= new Type<RevealContentHandler<?>>();
	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_sideRight = new Type<RevealContentHandler<?>>();
	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_footer = new Type<RevealContentHandler<?>>();

	

	
	private final SearchFormPresenter searchFormPresenter;


	@Inject
	public MainPagePresenter(final EventBus eventBus, final MyView view, final MyProxy proxy, SearchFormPresenter searchFormPresenter) {
		super(eventBus, view, proxy);
		this.searchFormPresenter = searchFormPresenter;
	}

	@Override
	protected void revealInParent() {
		RevealRootContentEvent.fire(this, this);
	}

	@Override
	protected void onReveal() {
		super.onReveal();
		setInSlot(TYPE_sideRight, searchFormPresenter);
		getView().setInSlot(TYPE_content, new Label("Уточните параметры поиска"));
	}
	@Override
	protected void onBind() {
		super.onBind();
	}

	@Override
	protected void onReset() {
		super.onReset();
	}

}
